package com.qjl.shopping.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qjl.shopping.bean.Admin;
import com.qjl.shopping.bean.Game;
import com.qjl.shopping.bean.Item;
import com.qjl.shopping.dao.AdminMapper;
import com.qjl.shopping.dao.ItemMapper;
import com.qjl.shopping.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author liguanghui
 * @Date 2023/5/3
 */
@Service
public class ItemServiceImpl extends ServiceImpl<ItemMapper, Item> implements ItemService {
    @Autowired
    private ItemMapper itemMapper;
    @Override
    public Page<Item> selectPage(int pageNum, int pageSize,int gameId,int type,int rule,int status,String name) {
        Page<Item> page = new Page<>(pageNum,pageSize);
        QueryWrapper queryWrapper = new QueryWrapper();
        if(gameId!=0){
            queryWrapper.eq("item_gameid",gameId);
        }
        if(!name.equals("")){
            queryWrapper.like("item_name",name);
        }
        if (type!=0){
            queryWrapper.eq("item_type",type);
        }
        if (type!=0){
            queryWrapper.eq("item_type",type);
        }
        if(status!=0){
            queryWrapper.eq("item_status",status);
        }
        if(rule==2){
            queryWrapper.orderByDesc("item_price");
        }
        Page<Item> itemPage = itemMapper.selectPage(page,queryWrapper);
        return itemPage;
    }
}
